## This test is checking the handling of invalid/malformed note entries for
## AMDGPU code object v2.

# RUN: yaml2obj %s -o %t.o
# RUN: llvm-readobj --notes %t.o | FileCheck %s --match-full-lines --check-prefix=LLVM
# RUN: llvm-readelf --notes %t.o | FileCheck %s --match-full-lines --check-prefix=GNU

# LLVM:      Notes [
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_hsa_code_object_version_0
# LLVM-NEXT:     Offset: 0x40
# LLVM-NEXT:     Size: 0x14
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0x4
# LLVM-NEXT:       Type: NT_AMD_HSA_CODE_OBJECT_VERSION (AMD HSA Code Object Version)
# LLVM-NEXT:       AMD HSA Code Object Version: Invalid AMD HSA Code Object Version
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_hsa_code_object_version_1
# LLVM-NEXT:     Offset: 0x54
# LLVM-NEXT:     Size: 0x1C
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0xC
# LLVM-NEXT:       Type: NT_AMD_HSA_CODE_OBJECT_VERSION (AMD HSA Code Object Version)
# LLVM-NEXT:       AMD HSA Code Object Version: Invalid AMD HSA Code Object Version
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_hsa_hsail_0
# LLVM-NEXT:     Offset: 0x70
# LLVM-NEXT:     Size: 0x1C
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0xA
# LLVM-NEXT:       Type: NT_AMD_HSA_HSAIL (AMD HSA HSAIL Properties)
# LLVM-NEXT:       AMD HSA HSAIL Properties: Invalid AMD HSA HSAIL Properties
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_hsa_hsail_1
# LLVM-NEXT:     Offset: 0x8C
# LLVM-NEXT:     Size: 0x24
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0x14
# LLVM-NEXT:       Type: NT_AMD_HSA_HSAIL (AMD HSA HSAIL Properties)
# LLVM-NEXT:       AMD HSA HSAIL Properties: Invalid AMD HSA HSAIL Properties
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version_0
# LLVM-NEXT:     Offset: 0xB0
# LLVM-NEXT:     Size: 0x18
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0x8
# LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
# LLVM-NEXT:       AMD HSA ISA Version: Invalid AMD HSA ISA Version
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version_1
# LLVM-NEXT:     Offset: 0xC8
# LLVM-NEXT:     Size: 0x28
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0x17
# LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
# LLVM-NEXT:       AMD HSA ISA Version: Invalid AMD HSA ISA Version
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version_2
# LLVM-NEXT:     Offset: 0xF0
# LLVM-NEXT:     Size: 0x28
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0x17
# LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
# LLVM-NEXT:       AMD HSA ISA Version: Invalid AMD HSA ISA Version
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_hsa_isa_version_3
# LLVM-NEXT:     Offset: 0x118
# LLVM-NEXT:     Size: 0x28
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0x17
# LLVM-NEXT:       Type: NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
# LLVM-NEXT:       AMD HSA ISA Version: Invalid AMD HSA ISA Version
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT:   NoteSection {
# LLVM-NEXT:     Name: .note.nt_amd_pal_metadata
# LLVM-NEXT:     Offset: 0x140
# LLVM-NEXT:     Size: 0x14
# LLVM-NEXT:     Note {
# LLVM-NEXT:       Owner: AMD
# LLVM-NEXT:       Data size: 0x4
# LLVM-NEXT:       Type: NT_AMD_PAL_METADATA (AMD PAL Metadata)
# LLVM-NEXT:       AMD PAL Metadata: Invalid AMD PAL Metadata
# LLVM-NEXT:     }
# LLVM-NEXT:   }
# LLVM-NEXT: ]

# GNU:       Displaying notes found in: .note.nt_amd_hsa_code_object_version_0
# GNU-NEXT:    Owner                Data size        Description
# GNU-NEXT:    AMD                  0x00000004       NT_AMD_HSA_CODE_OBJECT_VERSION (AMD HSA Code Object Version)
# GNU-NEXT:      AMD HSA Code Object Version:
# GNU-NEXT:          Invalid AMD HSA Code Object Version
# GNU-EMPTY:
# GNU-NEXT:  Displaying notes found in: .note.nt_amd_hsa_code_object_version_1
# GNU-NEXT:    Owner                Data size        Description
# GNU-NEXT:    AMD                  0x0000000c       NT_AMD_HSA_CODE_OBJECT_VERSION (AMD HSA Code Object Version)
# GNU-NEXT:      AMD HSA Code Object Version:
# GNU-NEXT:          Invalid AMD HSA Code Object Version
# GNU-EMPTY:
# GNU-NEXT:  Displaying notes found in: .note.nt_amd_hsa_hsail_0
# GNU-NEXT:    Owner                Data size        Description
# GNU-NEXT:    AMD                  0x0000000a       NT_AMD_HSA_HSAIL (AMD HSA HSAIL Properties)
# GNU-NEXT:      AMD HSA HSAIL Properties:
# GNU-NEXT:          Invalid AMD HSA HSAIL Properties
# GNU-EMPTY:
# GNU-NEXT:  Displaying notes found in: .note.nt_amd_hsa_hsail_1
# GNU-NEXT:    Owner                Data size        Description
# GNU-NEXT:    AMD                  0x00000014       NT_AMD_HSA_HSAIL (AMD HSA HSAIL Properties)
# GNU-NEXT:      AMD HSA HSAIL Properties:
# GNU-NEXT:          Invalid AMD HSA HSAIL Properties
# GNU-EMPTY:
# GNU-NEXT:  Displaying notes found in: .note.nt_amd_hsa_isa_version_0
# GNU-NEXT:    Owner                Data size        Description
# GNU-NEXT:    AMD                  0x00000008       NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
# GNU-NEXT:      AMD HSA ISA Version:
# GNU-NEXT:          Invalid AMD HSA ISA Version
# GNU-EMPTY:
# GNU-NEXT:  Displaying notes found in: .note.nt_amd_hsa_isa_version_1
# GNU-NEXT:    Owner                Data size        Description
# GNU-NEXT:    AMD                  0x00000017       NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
# GNU-NEXT:      AMD HSA ISA Version:
# GNU-NEXT:          Invalid AMD HSA ISA Version
# GNU-EMPTY:
# GNU-NEXT: Displaying notes found in: .note.nt_amd_hsa_isa_version_2
# GNU-NEXT:   Owner                Data size        Description
# GNU-NEXT:   AMD                  0x00000017       NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
# GNU-NEXT:     AMD HSA ISA Version:
# GNU-NEXT:         Invalid AMD HSA ISA Version
# GNU-EMPTY:
# GNU-NEXT:  Displaying notes found in: .note.nt_amd_hsa_isa_version_3
# GNU-NEXT:    Owner                Data size        Description
# GNU-NEXT:    AMD                  0x00000017       NT_AMD_HSA_ISA_VERSION (AMD HSA ISA Version)
# GNU-NEXT:      AMD HSA ISA Version:
# GNU-NEXT:          Invalid AMD HSA ISA Version
# GNU-EMPTY:
# GNU-NEXT:  Displaying notes found in: .note.nt_amd_pal_metadata
# GNU-NEXT:    Owner                Data size        Description
# GNU-NEXT:    AMD                  0x00000004       NT_AMD_PAL_METADATA (AMD PAL Metadata)
# GNU-NEXT:      AMD PAL Metadata:
# GNU-NEXT:          Invalid AMD PAL Metadata

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_REL
Sections:
  - Name:     .note.nt_amd_hsa_code_object_version_0
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_HSA_CODE_OBJECT_VERSION
        ## Desc size is too small (less than sizeof(CodeObjectVersion)).
        Desc: '02000000'
  - Name:     .note.nt_amd_hsa_code_object_version_1
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_HSA_CODE_OBJECT_VERSION
        ## Desc size is too large (more than sizeof(CodeObjectVersion)).
        Desc: '020000000200000002000000'
  - Name:     .note.nt_amd_hsa_hsail_0
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_HSA_HSAIL
        ## Desc size is too small (less than sizeof(HSAILProperties)).
        Desc: '02000000010000000102'
  - Name:     .note.nt_amd_hsa_hsail_1
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_HSA_HSAIL
        ## Desc size is too large (more than sizeof(HSAILProperties)).
        Desc: '0200000001000000010202000000010200000001'
  - Name:     .note.nt_amd_hsa_isa_version_0
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_HSA_ISA_VERSION
        ## Desc size is too small (less than sizeof(IsaVersion)).
        Desc: '0400070008000000'
  - Name:     .note.nt_amd_hsa_isa_version_1
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_HSA_ISA_VERSION
        ## Desc size is too small (less than sizeof(IsaVersion) +
        ## VendorNameSize + ArchitectureNameSize).
        Desc: '04000700080000000000000002000000414d4400414d44'
  - Name:     .note.nt_amd_hsa_isa_version_2
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_HSA_ISA_VERSION
        ## VendorNameSize is 0.
        Desc: '00000700080000000000000002000000414d4400414d44'
  - Name:     .note.nt_amd_hsa_isa_version_3
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_HSA_ISA_VERSION
        ## ArchitectureNameSize is 0.
        Desc: '04000000080000000000000002000000414d4400414d44'
  - Name:     .note.nt_amd_pal_metadata
    Type:     SHT_NOTE
    Notes:
      - Name: AMD
        Type: NT_AMD_PAL_METADATA
        ## Desc size is not a multiple of sizeof(PALMetadata).
        Desc: '02000000'
